//
//  BestAppDelegate.m
//  Best
//
//  Created by iDeneb on 7/25/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "BestAppDelegate.h"

@implementation BestAppDelegate

@synthesize window;
@synthesize tabBarController;
@synthesize navigationController;
@synthesize settingsController,firstViewController,newsViewController,orderViewController,contactViewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	
	self.firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstView" bundle:nil];
	[window addSubview:[firstViewController view]];
    // Override point for customization after application launch
    [window makeKeyAndVisible];
}

- (void) initTabView{
	self.settingsController = [[[SettingsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
	UINavigationController *settingsNavigationController = [[[UINavigationController alloc] initWithRootViewController:self.settingsController] autorelease];
	//settingsController.tabBarItem.image = [UIImage imageNamed:iconName];
	settingsController.title = NSLocalizedString(@"settings", @""); 
	
	self.newsViewController = [[[NewsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
	UINavigationController *newsNavigationController = [[[UINavigationController alloc] initWithRootViewController:self.newsViewController] autorelease];
	//newsViewController.tabBarItem.image = [UIImage imageNamed:iconName];
	newsViewController.title = NSLocalizedString(@"news", @""); 
	
	self.orderViewController = [[[OrderViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
	UINavigationController *ordersNavigationController = [[[UINavigationController alloc] initWithRootViewController:self.orderViewController] autorelease];
	//orderViewController.tabBarItem.image = [UIImage imageNamed:iconName];
	orderViewController.title = NSLocalizedString(@"orders", @""); 
	
	self.contactViewController = [[[ContactViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
	UINavigationController *contactsNavigationController = [[[UINavigationController alloc] initWithRootViewController:self.contactViewController] autorelease];
	//contactViewController.tabBarItem.image = [UIImage imageNamed:iconName];
	contactViewController.title = NSLocalizedString(@"contacts", @""); 
	
	// Set up tab bar
	self.tabBarController = [[UITabBarController alloc] init];
	[self.tabBarController setViewControllers:[NSArray arrayWithObjects:newsNavigationController, ordersNavigationController,contactsNavigationController,settingsNavigationController, nil]];
	
	for(NSInteger i=0;i<[window.subviews count];i++){
		[[window.subviews objectAtIndex:i] removeFromSuperview];
	}
	
	[window addSubview: tabBarController.view];
}

- (void)dealloc {
    [window release];
    [super dealloc];
}


@end
